package com.david.core

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.david.core.imgloader.LruImageLoader
import com.david.core.utils.dp
import com.david.core.utils.sp

class CoreTestMainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main_core_test)
        findViewById<View>(R.id.test).setOnClickListener {
            LruImageLoader.getInstance().init(application)
            //                LruImageLoader.getInstance().loadCacheImage("https://img-blog.csdnimg.cn/20190730180225124.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1ODI3MDEz,size_16,color_FFFFFF,t_70",findViewById<ImageView>(R.id.image_view))
            LruImageLoader.getInstance().createBuilder()
                .setUrl("https://img-blog.csdnimg.cn/20190730180225124.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzE1ODI3MDEz,size_16,color_FFFFFF,t_70")
                //                    .setImageView(findViewById<ImageView>(R.id.image_view))
                //                    .setErrorImgId(errorImgId)
                //                    .setLoadImgId(loadImgId)
                //                    .setTag("core")
                .setImageSavedListener(object : LruImageLoader.IImageSavedListener {
                    override fun onImageSaved(path: String?) {
                        Log.i("lru", "image saved in $path")
                    }

                    override fun onImageSaveFail(errMsg: String?) {
                        Log.i("lru", "image saved fail: $errMsg")
                    }

                })
                .startLoad()
        }

        12.dp
        12f.dp
        12f.sp
    }
}